package com.manage.server.controller.admin;

import com.manage.dto.ActivityDTO;
import com.manage.dto.add.ActivityAddDTO;
import com.manage.dto.update.ActivityUpdateDTO;
import com.manage.result.PageResult;
import com.manage.server.service.ActivityService;

import com.manage.vo.ActivityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.manage.result.Result;

@RestController
@RequestMapping("/activity")
public class ActivityController {

    @Autowired
    private ActivityService activityService;

    @PostMapping
    public Result add(@RequestBody ActivityAddDTO activityAddDTO) {
        activityService.save(activityAddDTO);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        activityService.removeById(id);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody ActivityUpdateDTO activityUpdateDTO) {
        activityService.updateById(activityUpdateDTO);
        return Result.success();
    }

    /**
     * 多项分类分页查询
     * @param activityDTO
     * @return
     */
    @PostMapping("/page")
    public PageResult<ActivityVO> findActivity(@RequestBody ActivityDTO activityDTO){
        return activityService.findActivityByPage(activityDTO);
    }
}
